log using "\\file\UsersW$\wrr15\Home\My Documents\My Files\META-ANALYSIS AND PUBLICATION BIAS\REVISION FOR RESEARCH SYNTHESIS METHODS\PROGRAMS\TABLE4PREneg.smcl", replace
// This program takes about 19 hours to run on a standard laptop
etime, start
drop _all
clear
graph drop _all
set more off
set seed 13
set matsize 5000
matrix FAT = J(9,2,0)
matrix PETFPP = J(9,2,0)
local studies = 100
local estperstudy = 10
local totalobs = `studies'*`estperstudy'
local theta = 1
local obs = 100
// Simulations are initially set to 5, which takes 6-7 minutes to run.
// To match the results in the paper, change to 10,000, but note that the
// program takes about 10 days to run with this many replications.
local reps = 1000

local i = 1
foreach alpha in 0 0.5 1 1.5 2 2.5 3 3.5 4 {
               simulate pvalue_FAT = r(pvalue_FAT) N = r(N) ///
pvalue_PETFPP = r(pvalue_PETFPP) effect_FPP = r(effect_FPP) pvalue_FPP = r(pvalue_FPP) , ///
                reps(`reps'): PANELpbias, studies(`studies') estperstudy(`estperstudy') totalobs(`totalobs') ///	
				alpha(`alpha') theta(`theta') obs(`obs')
						 
summ N, meanonly
matrix FAT[`i',1] = r(mean)/1000
generate RRFAT = 0
replace RRFAT = cond(pvalue_FAT<0.05,1,0) 
summ RRFAT, meanonly
matrix FAT[`i',2] = r(mean)

summ N, meanonly
matrix PETFPP[`i',1] = r(mean)/1000
generate RRPETFPP = 0
replace RRPETFPP = cond(pvalue_PETFPP<0.05,1,0) 
summ RRPETFPP, meanonly
matrix PETFPP[`i',2] = r(mean)
				
	
               local `++i'
}

matrix colnames FAT = Percent FAT
matrix rownames FAT = A0 A0P5 A1 A1P5 A2 A2P5 A3 A3P5 A4
matrix colnames PETFPP = Percent PET
matrix rownames PETFPP = A0 A0P5 A1 A1P5 A2 A2P5 A3 A3P5 A4
matrix list FAT
matrix list PETFPP

etime

log close
